package cz.fimuni.pa165.frontend;

import javax.servlet.http.HttpServletRequest;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 *
 * @author Lukas Slovak
 */
@Controller
public class HomeController {

    @RequestMapping(value = "/")
    public String doHome(HttpServletRequest request) {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        String name = auth.getName(); 
        request.getSession().setAttribute("username", name);
        return "index";
    }
}
